Override Hash code when you override Equals (OHCE)

Description:

Generally, when a class overrides the method Object.Equals(), it should also override Object.GetHashCode() and vice versa, a class overriding Object.GetHashCode() should also override Object.Equals(). Otherwise, standard collection types, such as hash tables, may not work correctly with instances of this class.

Incorrect:

Attribute = class
    private
      value:TObject;

    public
      function Equals(o:TObject):boolean;override;
end;
...
function Attribute.Equals(o:TObject):boolean;
begin
  result := value.Equals(o);
end;

Correct:

Attribute = class
    private
      value:TObject;

    public
      function Equals(o:TObject):boolean;override;
      function GetHashCode():integer;override;
end;
...
function Attribute.Equals(o:TObject):boolean;
begin
  result := value.Equals(o);
end;

function Attribute.GetHashCode():integer;
begin
  result := value.GetHashCode();
end;